package com.dq.repository.org;

import com.dq.domain.reward.Reward;
import com.dq.domain.sys.user.user.StaffUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

/**
 * @author liuhui
 * @date 2019/11/28 0028 15:30:13
 */
@Repository
public interface RewardRepository extends JpaRepository<Reward,Long> {
    @Query("select COALESCE(sum(rewardPrice),0) from Reward where staffUser = ?1 and rewardCategory=?2 and createTime>=?3 and createTime<=?4")
    BigDecimal getReward(StaffUser staffUser, Reward.RewardCategory rewardCategory,Long beginTime,Long endTime);
}
